package com.qf.controller;

import com.qf.pojo.Student;
import com.qf.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by 54110 on 2021/6/22.
 */
@RestController
@RequestMapping("/student")
public class StudentController {

    @Autowired
    StudentService studentService;

    @RequestMapping("/findAll")
    public List<Student> findAll(){
        return studentService.findAll();
    }

    @RequestMapping("/findById")
    public Student findById(@RequestParam("id")Integer id){
        return studentService.findById(id);
    }

    @RequestMapping("/insertStudent")
    public String  insertStudent(@RequestBody Student student){
        return studentService.insert(student);
    }

    @RequestMapping("/updateStudent")
    public String updateStudent(@RequestBody Student student){
        return studentService.update(student);
    }

    @RequestMapping("/deleteById/{id}")
    public  String deleteById(@PathVariable("id")Integer id){
        return studentService.deleteById(id);
    }
}
